feat(referencePicker): introduce getReferenceWithPicker()#8532
Conversation
|
/backport to stable8 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8532 +/- ##
==========================================
- Coverage 54.57% 54.31% -0.26%
==========================================
Files 106 106
Lines 3443 3461 +18
Branches 1004 1009 +5
==========================================
+ Hits 1879 1880 +1
- Misses 1323 1336 +13
- Partials 241 245 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/backport to stable8 |
53cfef4 to
367d86b
Compare
638da91 to
7113c3d
Compare
ShGKme
left a comment
There was a problem hiding this comment.
If I understand the change correctly, the following components have changed public API:
NcReferencePickerNcSearch
481340b to
a4a1f78
Compare
Required for Text and Collectives to pass the link title from the picker (e.g. Collectives PagePicker.vue) to the consumer (menubar in Text). Signed-off-by: Jonas <jonas@freesources.org>
- In NcCustomPickerElement we cannot control the submitted type, so let's add the type check there as well. - NcSearch is exported publically and used by apps, so changing its return type would introduce a backwards-incompatibility. - NcProviderList, NcRawLinkInput and NcCustomPickerElement are not publically exposed, so we can change the emitted type there. Signed-off-by: Jonas <jonas@freesources.org>
a4a1f78 to
9e64b40
Compare
Requires nextcloud-libraries/nextcloud-vue#8532 to have an effect. Signed-off-by: Jonas <jonas@freesources.org>
|
nextcloud/text#8615 and nextcloud/collectives#2522 are the respective PRs in Text and Collectives to use this new feature. |
ShGKme
left a comment
There was a problem hiding this comment.
This PR changes API for custom picker elements - the submit event sends reference as an object instead of a string link.
This change for the custom picker element is not backward compatible. An object cannot be used where the string was expected.
All the components using this result are updated to support both the new object result and the old string link result. All the components are backward compatible and support old custom picker elements.
However, they are not forward compatible. Older nextcloud-vue version will break with new custom picker element.
For example, new Collectives's PagePicker custom picker element emits submit event with { link, title }. Then an old nextcloud-vue's getLinkWithPicker handle it as a string link.
For the smart picker it results in creating '[object Object]' text node.
Proposal 1: instead of changing the existing submit event, add a new event, submit-reference or just pick.
Then custom picker elements can emit both events. Where supported, the new event with extra data will be used, and where not - the old event still works.
Later we can mark the old event as deprecated and remove.
this.$el.dispatchEvent(new CustomEvent('submit', {
bubbles: true,
detail: pageLink,
}))
this.$el.dispatchEvent(new CustomEvent('pick', {
bubbles: true,
detail: {
link: pageLink,
title: page.title,
},
}))Proposal 2: submit a string with additional link and title properties. So it is still a string, but we can extract the details
const result = 'https://nextcloud.com'
result.link = 'https://nextcloud.com'
result.title = 'Nextcloud'Dirty. Hacky. Should work.
Proposal 3: emit an object with toString() method.
const result = {
link: 'https://nextcloud.com',
title: 'Nextcloud',
toString() => 'https://nextcloud.com',
}It is simpler, but will only work where the value is casted to string. For example, it works for the NcRichText with document.createTextNode(result). But it may not work for all the getLinkWithPicker users...
Required for Text and Collectives to pass the link title from the picker (e.g. Collectives PagePicker.vue) to the consumer (menubar in Text).
🏁 Checklist
stable8for maintained Vue 2 version or not applicable